<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<script type="text/javascript" src="scripts/boot.js"></script>
	<style type="text/css">
	.item{
		width: 120px;
		display: inline-block;
		margin-left: 5px;
	}
	</style>
</head>
<body style="border: 0px; margin: 0px; padding: 0px;width: 100%;height: 100%">
	<div class="mini-toolbar" style="border-bottom:0;padding:0px;">
		<table width="100%" border="0">
			<tr>
			   	<td  style="width:30%;">
			   	  <span class="item">订单编号(精确)：</span>
			      <input id="serialNum" class="mini-textbox" emptyText="请输入订单编号"  onenter="onKeyEnter" style="width:160px;"/>
			    </td>
			    <td  style="width:30%;">
			      <span class="item">收货人(精确)：</span>
			      <input id="name" class="mini-textbox" emptyText="请输入收货人"  onenter="onKeyEnter" style="width:160px;"/>
			    </td>
			 </tr>
			 <tr>
			   	<td  style="width:30%;">
			   	  <span class="item">下单时间(开始时间)：</span>
			      <input id="startTime" emptyText="请选择..." class="mini-datepicker" style="width:160px;" format="yyyy-MM-dd H:mm:ss" timeFormat="H:mm:ss" showTime="true" allowInput="false"/> 
			    </td>
			    <td  style="width:30%;">
			      <span class="item">下单时间(截至时间)：</span>
			      <input id="endTime" emptyText="请选择..." class="mini-datepicker" style="width:160px;" format="yyyy-MM-dd H:mm:ss" timeFormat="H:mm:ss" showTime="true" allowInput="false"/> 
			    </td>
			    <td style="white-space:nowrap;"><a class="mini-button" iconCls="icon-search" onclick="search()">查询</a> </td>
			 </tr>
		</table>          
	</div>
	<div class="mini-toolbar" style="border-bottom:0;padding:0px;">
	    <table style="width:100%;">
	        <tr>
	       	 	<td style="width:100%;">
                    <a class="mini-button" iconCls="icon-download" onclick="exportCurrent()">导出当前</a>
                    <a class="mini-button" iconCls="icon-download" onclick="exportAll()">导出全部</a>
                </td>
	        </tr>
       	</table>
     </div>
     <div class="mini-fit" >
	<div id="datagrid1" class="mini-datagrid" allowCellWrap="true" idField="id" pageSize="20" url="group_audit_view.do" style="width:100%;height:100%;" multiSelect="true">
		<div property="columns">
			<div type="indexcolumn"></div>
			<div name="action" width="70" headerAlign="center" align="center" renderer="ordersDetail">订单详情</div>
			<div field="serialNum" width="60" headerAlign="center" align="center" >编号</div>
			<div field="cusSerName" width="60" headerAlign="center" align="center" >客服代表</div>
			<div field="createTime" width="115" headerAlign="center" align="center" allowSort="true" dateFormat="yyyy-MM-dd HH:mm:ss">下单时间</div>
			<div field="name" width="50" headerAlign="center" align="center" >收货人</div>
			<div field="pName" width="50" headerAlign="center" align="center" >省</div>
			<div field="cName" width="50" headerAlign="center" align="center" >市</div>
			<div field="dName" width="50" headerAlign="center" align="center" >区</div>
			<div field="address" width="150" headerAlign="center" align="center" >发货地址</div>
			<div field="payment" width="60" headerAlign="center" align="center" >货款金额</div>
			<div field="freight" width="50" headerAlign="center" align="center" >运费</div>
			<div field="mediaName" width="50" headerAlign="center" align="center" >媒体</div>
		</div>
	</div>
	</div>

<script type="text/javascript">
	mini.parse();
	
	var grid = mini.get("datagrid1");
	grid.load();
	
	//导出当前
	function exportCurrent(){
	 	var data = grid.data;
        var ids = [];
        $.each(data , function(){
            ids.push(this.id);
        });
        var id = ids.join(',');
        location.href="audit_init_export_current.do?ids=" +id;
        grid.reload();
	}
	
	//导出所有
	function exportAll(){
		location.href="audit_group_export_all.do";
	}

	//相关操作
 	function ordersDetail(e) {
 		var record = e.record;
		return  '<a style="width:150px;" href="javascript: ordersView('+record._uid+')">查看订单</a>';
    }
    
    function ordersView(row_uid) {
    	var row = grid.getRowByUID(row_uid);
        mini.open({
        	url: "audit_orders_detail_init.do?id=" + row.id,
            title: "查看订单", width: 850, height: 650,
            allowResize: false,
            onload: function () {
                var iframe = this.getIFrameEl();
                var data = { row: row, type: 2};
                iframe.contentWindow.SetData(data);
            },
            ondestroy: function (action) {
            	if(action == "audit"){
            		mini.showMessageBox({
    	                title: "提示",
    	                showModal:false,
    	                iconCls: "mini-messagebox-info",
    	                message: "审核成功！",
    	                timeout: 3000,
    	                x: 'right',
    	                y: 'bottom',
    	            });
                	grid.reload();
	        	}
            }
        });
    }
	
    function search() {
    	var serialNum = mini.get("serialNum").getValue();
        var name = mini.get("name").getValue();
        var startTime = mini.get("startTime").getFormValue();
        var endTime = mini.get("endTime").getFormValue();
        grid.load({ 
        	serialNum: serialNum,
        	name: name,
        	startTime: startTime,
        	endTime: endTime
        });
    }
    
    function onKeyEnter(e) {
        search();
    }
</script>
</body>
</html>